package com.atguigu.srb.core.controller.api;


import com.atguigu.srb.common.result.R;
import com.atguigu.srb.core.entity.BorrowInfo;
import com.atguigu.srb.core.service.BorrowInfoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 借款信息表 前端控制器
 * </p>
 *
 * @author Atguigu
 * @since 2023-06-30
 */
@RestController
@RequestMapping("/api/core/borrowInfo")
public class ApiBorrowInfoController {
    @Resource
    private BorrowInfoService borrowInfoService;
    //提交借款人的信息
    @PostMapping("/auth/commitData")
    @ApiOperation("提交借款申请")
    public R commitAppication(@RequestBody BorrowInfo borrowInfo,
                              @RequestHeader(value = "token",required = false)String token){
        borrowInfoService.commitApplication(borrowInfo,token);
        return R.ok();
    }
    //查询借款用户的当前的状态
    @GetMapping("/auth/status")
    public R getBorrowStatus(@RequestHeader(value = "token",required = false)String token){
        //根据用户的id查询当前借款人的审批状态
        Integer status = borrowInfoService.getBorrowStatus(token);
        return R.ok().data("status",status);
    }
}

